<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="Cache-Control" content="No-Cache">
	<meta http-equiv="Pragma" content="No-Cache">

	<title>운세의 신</title>

	<link rel="stylesheet" type="text/css" href="/css/common.css">
	<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>

	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
	<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script> 
	<script src="/js/lib/myconfig.jquery.datepicker.js"></script>
	<script src="/js/utility/common_util.js"></script>
	<script src="/js/common_basic.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			
			$("#start_dt").datepicker();
			$("#end_dt").datepicker();
			$("img.ui-datepicker-trigger").attr("style","margin-left:5px; vertical-align:middle; cursor:pointer;"); //이미지버튼 style적용
			$("#ui-datepicker-div").hide(); //자동으로 생성되는 div객체 숨김 

			$("#btnTodaySetting").click(function() {
				$("#start_dt").val(getStrDate(0));
				$("#end_dt").val(getStrDate(0));
			});
			
			$("#btnWeekSetting").click(function() {
				$("#start_dt").val(getStrDate(-7));
				$("#end_dt").val(getStrDate(0));
			});
			
			$("#btnMonthSetting").click(function() {
				$("#start_dt").val(getStrDate(-31));
				$("#end_dt").val(getStrDate(0));
			});

			$("#btnThisMonthSetting").click(function() {
				var today = new Date();
				var endDay = new Date(today.getFullYear(), today.getMonth()+1, 0);
				var strToday = today.getFullYear() +"-"+ (today.getMonth()+1).lpad(2) +"-"+ "01";
				var strEndDay = endDay.getFullYear() +"-"+ (endDay.getMonth()+1).lpad(2) +"-"+ endDay.getDate();
				$("#start_dt").val(strToday);
				$("#end_dt").val(strEndDay);
			});
			
			$("#btnLastMonthSetting").click(function() {
				var today = new Date();
				var endDay = new Date(today.getFullYear(), today.getMonth()+1, 0);
				var strToday = today.getFullYear() +"-"+ (today.getMonth()).lpad(2) +"-"+ "01";
				var strEndDay = endDay.getFullYear() +"-"+ (endDay.getMonth()).lpad(2) +"-"+ endDay.getDate();
				$("#start_dt").val(strToday);
				$("#end_dt").val(strEndDay);
			});
			
			
			var divTicket = $(".divTicket");

			$(".btnTicket").each(function(index) {
				$(this).click(function(event) {
					//alert("x좌표 :"+event.pageX+" ; y좌표 :"+event.pageY);
					divTicket.hide();
					divTicket.eq(index).css('top' ,event.pageY-10);
					divTicket.eq(index).css('left',event.pageX-250);
					divTicket.eq(index).show();
				});
			});
			
			$(".btnCloseTicket").click(function() {
				divTicket.hide();
			});
		});

		function openMemberHistory(user_id) {
			openPopup('/member/member/member_history?user_id='+user_id,800,600);
		}

		// 페이지 이동
		function goPage(page) {
			$("#page").val(page);
			$("#frm").submit();
		}
	</script>
</head>
<body>
<div id="wrap">
	<!-- Header -->
	<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/commons/header.php'; ?>
	<!--// Header -->

	<!-- Contents -->
	<div id="content">
		<h2>회원관리 - 리스트 (총 <?=$total_cnt?>명)</h2>
		<div>
			<form method="get" name="frm" id="frm" action="/member/member">
				<input type="hidden" name="page" id="page" value="1" />
				<input type="hidden" name="order" id="order" value="<?=isset($_GET['order']) ? $_GET['order'] : 'artist_name'?>" />
				<input type="hidden" name="sort" id="sort" value="<?=isset($_GET['sort']) ? $_GET['sort'] : 'asc'?>" />
				
				<fieldset>
					이름 : <input type="text" name="user_name" id="user_name" value="<?=isset($_GET['user_name']) ? $_GET['user_name'] : ''?>" /><br/>
					닉네임 : <input type="text" name="nickname" id="nickname" value="<?=isset($_GET['nickname']) ? $_GET['nickname'] : ''?>" /><br/>
					아이디 : <input type="text" name="user_id" id="user_id" value="<?=isset($_GET['user_id']) ? $_GET['user_id'] : ''?>" /><br/>
					가입일 : <input type="text" name="start_dt" id="start_dt" value="<?=isset($_GET['start_dt']) ? $_GET['start_dt'] : ''?>" /> ~ <input type="text" name="end_dt" id="end_dt" value="<?=isset($_GET['end_dt']) ? $_GET['end_dt'] : ''?>" />
					<input type="button" value="당일" id="btnTodaySetting" />
					<input type="button" value="당월" id="btnThisMonthSetting" />
					<input type="button" value="전월" id="btnLastMonthSetting" />
					<input type="button" value="최근일주일" id="btnWeekSetting" />
					<input type="button" value="최근한달" id="btnMonthSetting" />
					<br/>
					<input type="submit" value="검색"/> <input type="button" value="검색취소" onclick="location.href='/member/member'"/>
				</fieldset>
			</form>
			<table class="basicTable" width="100%" cellpadding="2" cellspacing="1" border="0">
				<thead>
					<tr>
						<th>가입일</th>
						<th>회원아이디</th>
						<th>이름</th>
						<th>별명</th>
						<th>성별</th>
						<th>생년월일</th>
						<th>등급</th>
						<th>가입상품</th>
						<th>개별이용</th>
						<th>포인트</th>
						<th>캐쉬</th>
						<th>이메일</th>
						<th>연락처</th>
						<th>주소</th>
						<!--<th colspan="2">최종접속정보</th>-->
						<th>SMS</th>
						<th>Email</th>
						<th>활동이력</th>
					</tr>
				</thead>
				<tbody>
<?	foreach ($list as $items) : ?>
					<tr>
						<td align="center"><?=substr($items['create_dt'],0,10)?></td>
						<td align="center"><?=$items['user_id'];?></td>
						<td align="center"><?=$items['user_name'];?></td>
						<td align="center"><?=$items['nickname'];?></td>
						<td align="center"><?=$items['sex'] == 'M' ? '남' : '여';?></td>
						<td align="center"><?=$items['birthdate'];?></td>
						<td align="center"><?=$items['class_name'];?></td>
						<td align="center"><?=$items['package_name'];?></td>
						<td align="center">
<?		if (!empty($items['ticket'])) : ?>
							<a href="javascript:;" class="btnTicket">상세보기</a>
							<div class="divTicket" style="display:none; position:absolute; z-index:3; background-color:#FFF; border: 1px solid #000; width: 500px;">
								<a href="javascript:;" class="btnCloseTicket">닫기</a>
								<table width="100%">
									<thead>
										<th>이용권명</th>
										<th>사용여부</th>
										<th>발급일시</th>
										<th>사용일시</th>
									</thead>
									<tbody>
<?			foreach ($items['ticket'] as $ticket) : ?>
										<tr>
											<td align="center"><?=$ticket['service_name']?></td>
											<td align="center"><?=$ticket['used_yn'] == 'Y' ? 'O' : 'X'?></td>
											<td align="center"><?=$ticket['create_dt']?></td>
											<td align="center"><?=$ticket['used_yn'] == 'Y' ? $ticket['create_dt'] : '-'?></td>
										</tr>
<?			endforeach ?>
									</tbody>
								</table>								
							</div>
<?		else : ?>
							-
<?		endif ?>
						</td>
						<td align="right"><?=number_format($items['point'])?></td>
						<td align="right"><?=number_format($items['cash'])?></td>
						<td align="center"><?=$items['email'];?></td>
						<td align="center"><?=$items['cellphone'];?></td>
						<td align="left"><?=$items['addr1'];?></td>
						<!--<td align="center"><?=$items['login_dt'];?></td>
						<td align="center"><?=$items['login_ip'];?></td>-->
						<td align="center"><?=$items['sms_yn'];?></td>
						<td align="center"><?=$items['mailing_yn'];?></td>
						<td align="center"><button onclick="openMemberHistory('<?=$items['user_id']?>')">조회</button></td>
					</tr>
<?	endforeach ?>
				</tbody>
				<tfoot>
					<tr>
						<td colspan="17">
							<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/board/page_navi.php'; ?>
						</td>
					</tr>
				</tfoot>
			</table>
		</div>
	</div>
	<!--// Contents -->

	<!-- Footer -->
	<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/commons/footer.php'; ?>
	<!--// Footer -->
</div>
</body>
</html>